<!-- 会员中心主内容区 -->
<div class="page-article" id="main">
  <!-- 到货通知 -->
  <div id="member_notify" class="member-notify">
    <div class="member-title">
    </div>
    <div class="member-mod table-responsive" style="overflow: auto;">
      <table class="member-grid table table-bordered table-striped table-hover" style="text-align:center">
        <thead>
          <th><input class="member-check-all" type="checkbox" name="member_all_checked" value="all_check" checked=""></th>
		  <th><{t}>商品 Эскиз<{/t}></th>
		 <!-- <th><{t}>货号 Артикул<{/t}></th>
          <th><{t}>码段 Размерный ряд<{/t}></th>-->
		  <th><{t}>状态 Статус<{/t}></th>
		  <th><{t}>返点 Комиссия<{/t}></th>
          <th><{t}>金额 Сумма<{/t}></th>
          <th><{t}>操作 Операция<{/t}></th>
        </thead>
        <tbody <{if !($browser.name=="IE" && ($brower.ver == 6 || $browser.ver == 7))}> class="first"<{/if}>>
			<{foreach from=$goods item=goods name=name}>
			<tr <{if $smarty.foreach.name.iteration == 1}> class="first"<{/if}>>
                <!--正常可以上下架的商品-->
		  		<{if $goods.image_default_id && $goods.s_price gt 0}>
                <td><input class="member-check-obj" type="checkbox" name="member_objects_checked"  value="<{$goods.goods_id}>" checked=""></td>
		  		<{else}>
                <!--不能上下架的商品-->
                <td><input class="member-check-obj_dis" type="checkbox" name="member_objects_checked"  disabled  value="<{$goods.goods_id}>"></td>
		  		<{/if}>
				<!--<td>
					<{if $goods.image_default_id}><a href="<{link app=b2c ctl=site_product arg0=$goods.product.0.product_id}>" target="_blank" style=" display:block; margin:0 auto; text-align:center;white-space:nowrap; max-width:80px; overflow:hidden; text-overflow:ellipsis;"><img src="<{$goods.image_default_id|storager:'s'}>" width="40px;" style="vertical-align: middle;"></a><{/if}>
					<a href="<{link app=b2c ctl=site_product arg0=$goods.product.0.product_id}>" target="_blank" style=" display:block; margin:0 auto; text-align:center;white-space:nowrap; max-width:80px; overflow:hidden; text-overflow:ellipsis;"><{$goods.name|default:$goods.name}> <{$goods.spec_info|spec_desc}></a>
                    <input type="hidden" name="brand_name" class="brand_name" value="<{$goods.brand.brand_name}>">
				</td>-->


<td style="width:240px;">
          <div class="p-pic fl">
              <img alt="<{$items.name}>" src="<{$goods.image_default_id|storager:'s'}>">
              <input type="hidden" name="brand_name" class="brand_name" value="<{$goods.brand.brand_name}>">
          </div>
          <div class="fl">
              <a href="<{link app=b2c ctl=site_product arg0=$goods.product.0.product_id}>" target="_blank" style=" display:block; margin:0 auto; text-align:left;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;"><{$goods.name|default:$goods.name}> <{$goods.spec_info|spec_desc}></a>
              <div style="text-align:left;">货号 Артикул：<{$goods.product.0.bn}></div>
              <div>季节 Сезон：<{$goods.season}></div>
              <div>包装数量：<{$goods.unit_num}><{$goods.bag_unit}>/<{$goods.unit}></div>
              <div class="size_all">
                  <table class="table table-hover table-striped table-condensed table-bordered">
                      <{foreach from=$goods.params key=key item=item}>
                      <thead>
                      <tr class="small">
                          <{foreach from=$item key=key2 item=item2}>
                          <{if !empty($item2) && $item2 > 0 && $key2 != "Кол-во в упаковке" }>
                          <th><{$key2}></th>
                          <{/if}>
                          <{/foreach}>
                      </tr>
                      </thead>
                      <tbody>
                      <tr class="small">
                          <{foreach from=$item key=key2 item=item2}>
                          <{if !empty($item2) && $item2 > 0 && $key2 != "Кол-во в упаковке" }>
                          <td><{$item2}></td>
                          <{/if}>
                          <{/foreach}>
                      </tr>
                      </tbody>
                      <{/foreach}>
                  </table>
              </div>

          </div>

</td>








<!--
				<td class="hh_code"></td>
                <td class="size_all">

                </td>-->
				<td><{t}><{$goods.status == 'true' ? '上架 В продажу' : '下架 Снят с продажи'}><{/t}></td>
				<td>
					<{t}><{$goods.brand.account_mode == 'rebate' ? '返点 Комиссия' :'结算价 Цена расчетная:'}><{/t}>
                    <{$goods.brand.rebate|number:0}>%
				</td>
				<!--供应商在更新价格时编辑的是单价字段s_price或是cost 判断条件：sdb_b2c_brand.account_mode为rebate时，编辑s_price；为account时编辑cost。-->
				<td class="item-price edit_price">
                    <{t}>销售单价 Цена за ед. тов. <{/t}>: <span class="disabled_pirce xsj"><{$goods.s_price|cur_odr}></span>
                  <!--  <{if $goods.brand.account_mode == 'rebate'}>
                    <span class="edit_price_sell xsj"><{$goods.s_price|cur_odr}></span>
                    <{else}>-->

                  <!--  <{/if}>-->
					<br>
                    <{t}>采购价 Цена закупки <{/t}>: <span class="disabled_pirce cgj"><{$goods.cost|cur_odr}></span>
                   <!-- <{if $goods.brand.account_mode == 'account'}>
                    <span class="edit_price_sell cost cgj"><{$goods.cost|cur_odr}></span>
                    <{else}>-->

                   <!-- <{/if}>-->
                </td>
                <td class="actions">
                    <!--<a title="" class="btn btn-xs btn-primary" style="margin-bottom: 5px;" href="<{link app=b2c ctl=site_member act=goods_edit arg0=$goods.goods_id arg1=$opt}>"><{t}>编辑<{/t}></a>
                    <br/>-->
					<{if $goods.status eq 'true'}>
						<a class="btn btn-xs btn-danger btn-offsell" href="javascript:;"><{t}>下架Снят с продажи<{/t}></a>
					<{else}>
                    <{if $goods.image_default_id && $goods.s_price gt 0}>
						<a class="btn btn-xs btn-success btn-onsell" href="javascript:;"><{t}>上架В продажу<{/t}></a>
                    <{/if}><{/if}>
				</td>
			</tr>
			<{/foreach}>
        </tbody>
      </table>
    </div>
    <{pagers data=$pager}>
  </div>
</div>
<div class="modal fade"  role="dialog" data-backdrop="static" id="myModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal"><span>&times;</span></button>
                <h4 class="modal-title">价格修改</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <div class="form-group row">
                            <div class="col-md-6 brand_edit">品牌: <i></i></div>
                            <div class="col-md-6 article_edit">货号: <i></i></div>
                        </div>
                        <div class="form-group row">
                            <div class="col-md-12 type_price"><i></i>: <b></b></div>
                        </div>

                        <div class="form-group edit_pribox">
                            <label class="control-label"  id="end_price_labe">修改价格:</label>
                            <input id="end_price" type="text" class="form-control">
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" id="edit_save">保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    jQuery(document).ready(function () {


        var goods_id ='';
        var goods_price ='';
        var is_tag ='';
        jQuery('.edit_price_sell').on('click', function () {
            var type_price ='';
            goods_id =jQuery(this).parents('tr').find('.member-check-obj').val();
            is_tag ='';
            jQuery('.brand_edit i').text(jQuery(this).parents('tr').find('.brand_name').val());
            jQuery('.article_edit i').text(jQuery(this).parents('tr').find('.hh_code').text());
            jQuery('.type_price b').text(jQuery(this).text());
            if(jQuery(this).hasClass('cost')){
                type_price='采购价';
                is_tag='cost';
            }else{
                type_price='销售单价';
                is_tag='s_price';
            }
            jQuery('.type_price i').text(type_price);
            jQuery('#myModal').modal('show');
            jQuery('#end_price').val('');
        });
        jQuery('#edit_save').on('click', function () {
            goods_price =jQuery('#end_price').val();
            jQuery.ajax({
                url: "<{link app=b2c ctl=site_member act=business_update_goods_price}>",
                type: 'post',
                dataType: 'json',
                data: {'goods_id': goods_id, 'is_tag': is_tag, 'goods_price': goods_price},
                success: function (rs) {
                    if(rs.status=='success'){
                        jQuery('#myModal').modal('hide');
                        Message.success('<{t}>操作成功<{/t}>');
                        jQuery('.member-check-obj').each(function(){
                            if(jQuery(this).val()==rs.goods_id){
                                jQuery(this).parents('tr').find('.xsj').text(rs.s_price);
                                jQuery(this).parents('tr').find('.cgj').text(rs.cost);
                            }
                        });

                    }else{
                        Message.error('<{t}>操作失败<{/t}>');
                    }
                }
            });

        });
        /*选中问题*/
           jQuery('.member-check-all').click(function(){
               if(jQuery(this).prop('checked')==false){
                   jQuery('.member-check-obj').each(function(){
                       jQuery(this).prop({checked: false});
                   });
               }else{
                   jQuery('.member-check-obj').each(function(){
                       jQuery(this).prop({checked: true});
                   });
               }
           });
        jQuery('.member-check-obj').click(function(){
            var if_hsano =false;
            jQuery('.member-check-obj').each(function(){
                if(jQuery(this).prop('checked')==false){
                    if_hsano =true;
                }
            });
            if(if_hsano){
                jQuery('.member-check-all').prop({checked: false});
            }else{
                jQuery('.member-check-all').prop({checked: true});
            }
        });
        /*批量上下架*/
        jQuery(".all_do").click(function(){
            var is_sell='';
            var if_hsano =false;
            var check_item =[];
            if(jQuery(this).hasClass('onsell_all')){
                is_sell='on';
            }
            else{
                is_sell='off';
            }
            jQuery('.member-check-obj').each(function(){
                if(jQuery(this).prop('checked')==true){
                    if_hsano =true;
                }
            });
            if(if_hsano==false){
                Message.error('<{t}>请选择商品<{/t}>');
            }else{
                jQuery('.member-check-obj').each(function(){
                    if(jQuery(this).prop('checked')==true){
                        check_item.push(jQuery(this).val());
                    }
                });
                jQuery.ajax({
                    url: "<{link app=b2c ctl=site_member act=batch_goods_issell}>",
                    type: 'post',
                    dataType: 'json',
                    data: {'is_sell': is_sell, 'check_item': check_item},
                    success: function (rs) {
                       if(rs.status=='success'){
                           Message.success('<{t}>操作成功<{/t}>');
                           jQuery('.member-check-obj').each(function(){
                               if(jQuery(this).prop('checked')==true){
                                   window.location.reload();
                               }
                           });
                       }else{
                           Message.error('<{t}>操作失败<{/t}>');
                       }
                    }
                });
            }
        })
    });
	$('main').addEvents({
		//商品上架
		'click:relay(.btn-onsell)': function(e) {
			e.stop();
            var this_val =jQuery(this).parents('tr').find('.member-check-obj').val();
			Dialog.confirm('<{t}>确定产品上架<{/t}>！', function(e){
                if(e) async(this, {
                    url: "<{link app=b2c ctl=site_member act=goods_onsell}>",
                    method: 'post',
					data:{'goods_id': this_val, 'response_json': 'true'}
                });
            }.bind(this));
		},
		//商品下架
		'click:relay(.btn-offsell)': function(e) {
			e.stop();
            var this_val =jQuery(this).parents('tr').find('.member-check-obj').val();
			Dialog.confirm('<{t}>确定产品下架<{/t}>！', function(e){
                if(e) async(this, {
                    url: "<{link app=b2c ctl=site_member act=goods_offsell}>",
                    method: 'post',
					data:{'goods_id': this_val, 'response_json': 'true'}
                });
            }.bind(this));
		}
	});
</script>